Skip to main content

pacenotes_installer\wizard\page/
chrome.rs

1use windows_sys::Win32::Foundation::{HWND, LPARAM};
2use windows_sys::Win32::UI::Controls as ctl;
3use windows_sys::Win32::UI::WindowsAndMessaging as wm;
4
5/// The wizard buttons' ids from prsht.h; `PSM_SETNEXTTEXT` is ignored by this
6/// sheet, but setting the controls' text directly works.
7const ID_WIZBACK: u16 = 0x3023;
8pub const ID_WIZNEXT: u16 = 0x3024;
9pub const ID_WIZFINISH: u16 = 0x3025;
10
11/// The sheet owning a page, which handles the `PSM_*` messages.
12pub unsafe fn sheet(dialog: HWND) -> HWND {
13    wm::GetParent(dialog)
14}
15
16/// Enables exactly these wizard buttons.
17pub unsafe fn set_buttons(dialog: HWND, flags: u32) {
18    wm::SendMessageW(sheet(dialog), ctl::PSM_SETWIZBUTTONS, 0, flags as LPARAM);
19}
20
21/// Labels the primary button for this scene, on both Next and Finish since
22/// the sheet swaps which one shows, and translates Back and Cancel, which
23/// comctl32 would otherwise leave in the OS language.
24pub unsafe fn set_next_text(dialog: HWND, string_id: u16) {
25    let sheet = sheet(dialog);
26    let set = |control: u16, string_id: u16| {
27        let text = crate::i18n::to_wide(&crate::i18n::load_string(string_id));
28        wm::SetDlgItemTextW(sheet, control as i32, text.as_ptr());
29    };
30    set(ID_WIZNEXT, string_id);
31    set(ID_WIZFINISH, string_id);
32    set(ID_WIZBACK, crate::i18n::IDS_BTN_BACK);
33    set(crate::ui::IDCANCEL, crate::i18n::IDS_BTN_CANCEL);
34}
35
36/// Set on activation because this sheet ignores `PROPSHEETHEADERW::pszCaption`.
37pub unsafe fn set_sheet_caption(dialog: HWND) {
38    let caption = crate::i18n::load_string(crate::i18n::IDS_APP_TITLE);
39    crate::ui::set_window_text(sheet(dialog), &caption);
40}
41
42/// The scene title is a static in each template, because the Wizard97 header
43/// shows a title only beside a header bitmap that would cost size budget.
44pub unsafe fn set_header(dialog: HWND, string_id: u16) {
45    crate::ui::set_text(
46        dialog,
47        crate::wizard::control_ids::IDC_SCENE_TITLE,
48        string_id,
49    );
50}